-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[AutoDiff] Parameter indices data structure overhaul #24761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@swift-ci please test tensorflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hurray!
|
@swift-ci please test tensorflow Linux |
3 similar comments
|
@swift-ci please test tensorflow Linux |
|
@swift-ci please test tensorflow Linux |
|
@swift-ci please test tensorflow Linux |
|
@swift-ci please test tensorflow Linux |
4 similar comments
|
@swift-ci please test tensorflow Linux |
|
@swift-ci please test tensorflow Linux |
|
@swift-ci please test tensorflow Linux |
|
@swift-ci please test tensorflow Linux |
|
@swift-ci Please test tensorflow linux |
Introduce
AutoDiffIndexSubsetThis PR overhauls data structures used for parameter indices in the AutoDiff infrastructure in SIL.
Previously, we used
llvm::SmallBitVectorto represent differentiation parameter indices in both AST and SIL. It was not efficient, and most importantly there's no way to put this in an instruction without causing memory leaks.This change replaces all uses of
llvm::SmallBitVectorin SIL AutoDiff code paths with aASTContext-uniquedAutoDiffIndexSubset *where bits are stored as trailing objects.AutoDiffIndexSubsetdoes not have "parameter indices" in its name because it is not only designed for parameter indices, but also for result indices as we move to supporting multi-result differentiation.AutoDiffIndexSubsethas set operations likeisSubsetOf,isSupersetOf, andcontains, but it also has a special capacity property. All differentiable function's parameter indices data should store the number of parameters as capacity, so that the differentiation transform won't need special logic to check whether an index is out of range.Another minor change is the module format layout of
SILDifferentiableAttr. It used to store parameter indices as consecutiveboolbits, but now stores numeric parameter indices directly for efficiency.It will be necessary to refactor or eliminate
AutoDiffParameterIndicesto make use ofAutoDiffIndexSubset.AutoDiffParameterIndicesis at the AST level, so it is not in the scope for this PR.Unblocks #23482. Partially resolves TF-67.